package edu.mercer.sse.bkp;

import java.util.concurrent.TimeUnit;

import com.google.common.base.Optional;

/**
 * Parameter object for time arguments.<p>
 *
 */

public class Duration 
{
	/** TimeUnit: Java concurrent.TimeUnit */
	
	private Optional<TimeUnit> _unit = Optional.absent();
	
	/** Interval: Long */
	
	private Optional<Long> _interval = Optional.absent();

	
	/**
	 * Parameter object for time arguments.<p>
	 * 
	 * @param interval - Long number of seconds, microseconds, ...
	 * @param unit - TimeUnit constant for SECONDS, MILLISECONDS, ...
	 */

	Duration( final Long interval, final TimeUnit unit )
	{
		_interval = Optional.of( interval );
		_unit = Optional.of( unit );
		
	}//constructor
	
	
	/**
	 * Parameter object for time arguments.<p>
	 * 
	 * Default TimeUnit : MILLISECONDS
	 * 
	 * @param interval - Long number of milliseconds
	 */
	
	Duration( final Long interval )
	{
		_interval = Optional.of( interval );
		_unit = Optional.of( TimeUnit.MILLISECONDS );
		
	}//constructor

	
	/**
	 * Get interval.<p>
	 * 
	 * @return  Long interval of this Duration
	 */
	
	public Long interval(){ return _interval.get(); }

	
	/**
	 * Get time unit.<p>
	 * 
	 * @return  TimeUnit of this Duration
	 */
	
	public TimeUnit unit(){ return _unit.get(); }
	
}//class
